package com.cnswhy.cloud.server.common.entity.enumeration;

import com.cnswhy.cloud.common.core.base.BaseEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 
 * </p>
 *
 * @author cnswhy
 * @date 2020-10-14
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "SubWalletType", description = "子钱包类型")
public enum SubWalletType implements BaseEnum {

    /**
     * DEFAULT="默认钱包"
     */
    DEFAULT("默认钱包"),
    /**
     * IOT_BALANCE="云享设备"
     */
    IOT_BALANCE("云享设备"),
    /**
     * NOCARD_BALANCE="费率收益"
     */
    NOCARD_BALANCE("费率收益"),
    /**
     * USED_BALANCE="云享收益"
     */
    USED_BALANCE("云享收益"),

    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 跟就当前枚举的name匹配
     */
    public static SubWalletType match(String val, SubWalletType def) {
        return Stream.of(values()).parallel().filter((item) -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static SubWalletType get(String val) {
        return match(val, null);
    }

    public boolean eq(SubWalletType val) {
        return val == null ? false : eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "DEFAULT,IOT_BALANCE,NOCARD_BALANCE,USED_BALANCE", example = "DEFAULT")
    public String getCode() {
        return this.name();
    }

}
